import request from 'utilis/request'

/**
 * 获取文章列表 可筛选
 * @param {Object} params
 * @returns
 */
export const getArticles = (params) => {
  return request({
    url: '/mp/articles',
    params,
  })
}

/**
 *
 * @param {*} params
 * @returns
 */

export const delArticle = (id) => {
  return request({
    url: `/mp/articles/${id}`,
    method: 'DELETE',
  })
}

/**
 *
 * @param {*} id
 * @returns  发布文章
 */
export const publishArticle = (data, draft) => {
  return request.post(`/mp/articles?draft=${draft}`, data)
}

export const getArticleById = (id) => {
  return request.get(`/mp/articles/${id}`)
}

/**
 *
 * @param {*} id
 * @returns  编辑文章
 */
export const updateArticle = (data, draft, id) => {
  return request.put(`/mp/articles/${id}?draft=${draft}`, data)
}
